<!-- modal -->
<template>
  <transition name="slide">
    <div class="modal" v-show="showModal">
      <div class="mask"></div>
      <div
        class="modal-dialog"
        :class="{ small: modalType == 'small', medium: modalType == 'medium' }"
      >
        <div class="modal-header">
          <span class="title">{{ title }}</span>
          <i class="iconfont iconshachu-xue" @click="$emit('cancel')"></i>
        </div>
        <div class="modal-body">
          <slot name="body"></slot>
        </div>
        <div class="modal-footer">
          <el-button
            size="small"
            v-show="btnType == 3 || btnType == 2"
            @click="$emit('cancel')"
            >{{ cancelText }}</el-button
          >
          <el-button
            type="primary"
            size="small"
            v-show="btnType == 3 || btnType == 1"
            @click="$emit('submit')"
            >{{ sureText }}</el-button
          >
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    title: {
      type: String,
      default: "提示",
    },
    // modal的大小，小small，中middle，大large，表单form
    modalType: {
      type: String,
      default: "form",
    },
    // 按钮类型，1:确定，2:取消，3:确定取消
    btnType: {
      type: String,
      default: "3",
    },
    sureText: {
      type: String,
      default: "确定",
    },
    cancelText: {
      type: String,
      default: "取消",
    },
    showModal: Boolean,
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {},
  methods: {
    closeModal() {
      this.showModal = false;
    },
  },
};
</script>
<style lang="less" scoped>
@import "./../assets/less/modal.less";
</style>
